/**
 * 
 */
package org.dragonfire.parser.functions;

import org.dragonfire.parser.Equation;
import org.dragonfire.util.DString;

/**
 * @author Darth Android
 * @date Jul 21, 2007
 */
public class Length extends Function {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.dragonfire.parser.functions.Function#eval(org.dragonfire.parser.Equation,
	 *      java.lang.String[])
	 */
	@Override
	public String eval(Equation equ, String[] params) {
		String equation = params[0];
		equation = equ.eval(equation);
		if (Equation.isString(equation))
			return DString.extractString(equation).length() + "";
		return "0";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.dragonfire.parser.functions.Function#minParams()
	 */
	@Override
	public int minParams() {
		return 1;
	}
}
